﻿using Architecture.Common;
using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;

namespace Architecture.Api.Controllers
{
    public class BaseController : ControllerBase
    {
        protected virtual string? UserId => HttpContext.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

        protected virtual IdentityUser? identityUser => GetUserLoginById(UserId.ToInt32());

        private IdentityUser GetUserLoginById(int userId)
        {
            //根据用户Id查询当前登陆人的信息
            return new IdentityUser()
            {
                UserId = userId,
                UserName = ""
            };
        }
    }
}
